
package cn.nubia.admin.application.bean;

import cn.nubia.admin.application.apk.entity.ApkInfo;
import cn.nubia.admin.common.mybatis.annotations.Column;
import cn.nubia.admin.common.mybatis.annotations.Id;
import cn.nubia.admin.common.mybatis.annotations.Table;
import cn.nubia.admin.common.mybatis.annotations.UnColumn;
import cn.nubia.admin.common.utils.DateUtil;
import cn.nubia.admin.sysconfig.bean.CategoryConstruct;

import java.io.Serializable;
import java.util.Date;

/**
 * Created by justin on 15/6/29.
 CREATE TABLE `nb_soft` (
 `soft_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '软件id',
 `soft_name` varchar(100) DEFAULT NULL COMMENT '软件名称',
 `category_id` int(11) DEFAULT NULL COMMENT '分类id',
 `category_parent_id` int(11) DEFAULT NULL COMMENT '分类父id',
 `package_name` varchar(100) DEFAULT NULL COMMENT '包名（软件标识符）',
 `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
 `last_modify_time` int(11) DEFAULT NULL COMMENT '最后修改时间',
 `sys_stars_enable` tinyint(4) DEFAULT NULL COMMENT '是否开启系统星级',
 `sys_stars` decimal(9,1) DEFAULT NULL COMMENT '系统星级（0.5-5）',
 `comment_stars` decimal(9,1) DEFAULT NULL COMMENT '评论星级（0.5-5）',
 `is_accredit` tinyint(4) DEFAULT NULL COMMENT '是否授权（1-授权 0-未授权）',
 `is_official` tinyint(4) DEFAULT NULL COMMENT '是否官方（1-官方 0-非官方）',
 `developer_name` varchar(120) DEFAULT NULL COMMENT '开发者名称',
 `developer_phone` varchar(50) DEFAULT NULL COMMENT '开发者手机/电话',
 `developer_email` varchar(100) DEFAULT NULL COMMENT '开发者邮箱',
 `developer_site` varchar(100) DEFAULT NULL COMMENT '开发者网站',
 `download_number` int(11) DEFAULT NULL COMMENT '总下载量',
 `summary` varchar(500) DEFAULT NULL COMMENT '软件简介',
 `description` longtext COMMENT '软件详细内容',
 `seo` varchar(100) DEFAULT NULL COMMENT '搜索关键词（用空格隔开）',
 `last_soft_item_id` int(11) DEFAULT NULL COMMENT '最新版本的软件项目id，未上架用0',
 `last_publish_time` int(11) DEFAULT NULL COMMENT '最新版本的软件上架时间',
 `create_admin_id` int(11) DEFAULT NULL COMMENT '添加软件的管理员id',
 `create_admin_name` varchar(20) DEFAULT NULL COMMENT '添加软件的管理员名称',
 `is_delete` tinyint(4) DEFAULT NULL COMMENT '是否删除（1:删除  0: 正常）',
 PRIMARY KEY (`soft_id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='软件主体表';

 SET FOREIGN_KEY_CHECKS = 1;
 */
@Table(value = "nb_soft")
public class Soft implements Serializable{

    private static final long serialVersionUID = -8244661101951482489L;

    public static final Integer STATE_DELETE = 1;

    public static final String COLUMN_PACKAGENAME = "packageName";
    public static final String COLUMN_ID = "id";
    public static final String COLUMN_SOFTNAME = "softName";
    public static final String COLUMN_ISDELETE = "isDelete";
    public static final String COLUMN_LASTPUBLISHTIME ="lastPublishTime";

    @Id(value="soft_id")
    private Integer id;//软件id
    @Column(value = "soft_name")
    private String softName;//软件名称
    @Column(value = "category_id")
    private Integer categoryId;//分类id
    @Column(value = "category_parent_id")
    private Integer categoryParentId;//分类父id
    @Column(value = "package_name")
    private String packageName;//包名（软件标识符）
    @Column(value = "create_time")
    private Integer createTime;//创建时间
    @Column(value = "last_modify_time")
    private Integer lastModifyTime;//最后修改时间
    @Column(value = "sys_stars_enable")
    private Integer sysStarsEnable;//是否开启系统星级
    @Column(value = "sys_stars")
    private Float sysStars;//系统星级（0.5-5）
    @Column(value = "comment_stars")
    private Float commentStars;//评论星级（0.5-5）
    @Column(value = "is_accredit")
    private Integer isAccredit;//是否授权（1-授权 0-未授权）
    @Column(value = "is_official")
    private Integer isOfficial;//是否官方（1-官方 0-非官方）
    @Column(value = "developer_name")
    private String developerName;//开发者名称
    @Column(value = "developer_phone")
    private String developerPhone;//开发者手机/电话
    @Column(value = "developer_email")
    private String developerEmail;//开发者邮箱
    @Column(value = "developer_site")
    private String developerSite;//开发者网站
    @Column(value = "download_number")
    private Integer downloadNumber;//总下载量
    @Column(value = "summary")
    private String summary;//软件简介
    @Column(value = "description")
    private String description;//软件详细内容
    @Column(value = "seo")
    private String seo;//搜索关键词（用空格隔开）
    @Column(value = "last_soft_item_id")
    private Integer lastSoftItemId;//最新版本的软件项目id，未上架用0
    @Column(value = "last_publish_time")
    private Integer lastPublishTime;//最新版本的软件上架时间
    @Column(value = "create_admin_id")
    private Integer createAdminId;//添加软件的管理员id
    @Column(value = "create_admin_name")
    private String createAdminName;//添加软件的管理员名称
    @Column(value = "is_delete")
    private Integer isDelete;//是否删除（1:删除  0: 正常）

    @UnColumn
    private String iconUrl;
    @UnColumn
    private String createTimeShow;
    @UnColumn
    private String firstCategoryName;
    @UnColumn
    private String secCategoryName;
    @UnColumn
    private String thirdCategoryName;

    public Soft(){}

    public Soft(ApkInfo apkInfo) {
        this.packageName = apkInfo.getPackageName();
        this.softName = apkInfo.getApplicationLable();
        this.createTime = DateUtil.getCurrentTime();
    }

    public void copyStakeProperties(Soft soft){
        this.createAdminId = soft.getCreateAdminId();
        this.createAdminName = soft.getCreateAdminName();
        this.createTime = soft.getCreateTime();
        this.lastPublishTime = soft.getLastPublishTime();
    }

    public void initCategoryName(CategoryConstruct categoryConstruct) {
        if(categoryConstruct!=null){
            this.setFirstCategoryName(categoryConstruct.getFirstCategoryName());
            this.setSecCategoryName(categoryConstruct.getSecCategoryName());
            this.setThirdCategoryName(categoryConstruct.getThirdCategoryName());
        }
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getSoftName() {
        return softName;
    }

    public void setSoftName(String softName) {
        this.softName = softName;
    }

    public Integer getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(Integer categoryId) {
        this.categoryId = categoryId;
    }

    public Integer getCategoryParentId() {
        return categoryParentId;
    }

    public void setCategoryParentId(Integer categoryParentId) {
        this.categoryParentId = categoryParentId;
    }

    public String getPackageName() {
        return packageName;
    }

    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }




    public Float getCommentStars() {
        return commentStars;
    }

    public void setCommentStars(Float commentStars) {
        this.commentStars = commentStars;
    }

    public Float getSysStars() {
        return sysStars;
    }

    public void setSysStars(Float sysStars) {
        this.sysStars = sysStars;
    }


    public String getDeveloperName() {
        return developerName;
    }

    public void setDeveloperName(String developerName) {
        this.developerName = developerName;
    }

    public String getDeveloperPhone() {
        return developerPhone;
    }

    public void setDeveloperPhone(String developerPhone) {
        this.developerPhone = developerPhone;
    }

    public String getDeveloperEmail() {
        return developerEmail;
    }

    public void setDeveloperEmail(String developerEmail) {
        this.developerEmail = developerEmail;
    }

    public String getDeveloperSite() {
        return developerSite;
    }

    public void setDeveloperSite(String developerSite) {
        this.developerSite = developerSite;
    }

    public Integer getDownloadNumber() {
        return downloadNumber;
    }

    public void setDownloadNumber(Integer downloadNumber) {
        this.downloadNumber = downloadNumber;
    }

    public String getSummary() {
        return summary;
    }

    public void setSummary(String summary) {
        this.summary = summary;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getSeo() {
        return seo;
    }

    public void setSeo(String seo) {
        this.seo = seo;
    }

    public Integer getLastSoftItemId() {
        return lastSoftItemId;
    }

    public void setLastSoftItemId(Integer lastSoftItemId) {
        this.lastSoftItemId = lastSoftItemId;
    }

    public Integer getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Integer createTime) {
        this.createTime = createTime;
        if(createTime > 0){
            this.setCreateTimeShow(DateUtil.getFormatDate(this.getCreateTime()));
        }
    }

    public Integer getLastModifyTime() {
        return lastModifyTime;
    }

    public void setLastModifyTime(Integer lastModifyTime) {
        this.lastModifyTime = lastModifyTime;
    }

    public Integer getLastPublishTime() {
        return lastPublishTime;
    }

    public void setLastPublishTime(Integer lastPublishTime) {
        this.lastPublishTime = lastPublishTime;
    }

    public Integer getCreateAdminId() {
        return createAdminId;
    }

    public void setCreateAdminId(Integer createAdminId) {
        this.createAdminId = createAdminId;
    }

    public String getCreateAdminName() {
        return createAdminName;
    }

    public void setCreateAdminName(String createAdminName) {
        this.createAdminName = createAdminName;
    }


    public Integer getIsAccredit() {
        return isAccredit;
    }

    public void setIsAccredit(Integer isAccredit) {
        this.isAccredit = isAccredit;
    }

    public Integer getSysStarsEnable() {
        return sysStarsEnable;
    }

    public void setSysStarsEnable(Integer sysStarsEnable) {
        this.sysStarsEnable = sysStarsEnable;
    }

    public Integer getIsOfficial() {
        return isOfficial;
    }

    public void setIsOfficial(Integer isOfficial) {
        this.isOfficial = isOfficial;
    }

    public Integer getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(Integer isDelete) {
        this.isDelete = isDelete;
    }

    public String getIconUrl() {
        return iconUrl;
    }

    public void setIconUrl(String iconUrl) {
        this.iconUrl = iconUrl;
    }

    public String getCreateTimeShow() {
        return createTimeShow;
    }

    public void setCreateTimeShow(String createTimeShow) {
        this.createTimeShow = createTimeShow;
    }

    public String getFirstCategoryName() {
        return firstCategoryName;
    }

    public void setFirstCategoryName(String firstCategoryName) {
        this.firstCategoryName = firstCategoryName;
    }

    public String getSecCategoryName() {
        return secCategoryName;
    }

    public void setSecCategoryName(String secCategoryName) {
        this.secCategoryName = secCategoryName;
    }

    public String getThirdCategoryName() {
        return thirdCategoryName;
    }

    public void setThirdCategoryName(String thirdCategoryName) {
        this.thirdCategoryName = thirdCategoryName;
    }
}
